package com.tiyende.kash.loop.weight.city

class EntityWrapper<T> {

    companion object {
        const val TYPE_TITLE = Int.MAX_VALUE - 1
        const val TYPE_CONTENT = Int.MAX_VALUE
        const val TYPE_HEADER = 1
        const val TYPE_FOOTER = 2
    }

    private var index: String? = null
    private var indexTitle: String? = null
    private var cityName: String? = null
    private var indexByField: String? = null
    private var data: T? = null
    private var originalPosition = -1
    private var itemType: Int = TYPE_CONTENT
    private var headerFooterType = 0

    constructor()

    constructor(index: String?, itemType: Int){
        this.index = index
        indexTitle = index
        cityName = index
        this.itemType = itemType
    }

    fun getIndex(): String {
        return index!!
    }

    fun setIndex(index: String?) {
        this.index = index
    }

    fun getIndexTitle(): String {
        return indexTitle!!
    }

    fun setIndexTitle(indexTitle: String?) {
        this.indexTitle = indexTitle
    }

    fun getCityName(): String {
        if (cityName == null){
            return ""
        }
        cityName?.let {
            return it
        }
        return ""
    }

    fun setCityName(cityName: String?) {
        this.cityName = cityName
    }

    fun getIndexByField(): String? {
        return indexByField
    }

    fun setIndexByField(indexByField: String?) {
        this.indexByField = indexByField
    }

    fun getData(): T? {
        return data
    }

    fun setData(data: T) {
        this.data = data
    }

    fun getOriginalPosition(): Int {
        return originalPosition
    }

    fun setOriginalPosition(originalPosition: Int) {
        this.originalPosition = originalPosition
    }

    fun getItemType(): Int {
        return itemType
    }

    fun setItemType(itemType: Int) {
        this.itemType = itemType
    }

    fun getHeaderFooterType(): Int {
        return headerFooterType
    }

    fun setHeaderFooterType(headerFooterType: Int) {
        this.headerFooterType = headerFooterType
    }

    fun isTitle(): Boolean {
        return itemType == TYPE_TITLE
    }

    fun isContent(): Boolean {
        return itemType == TYPE_CONTENT
    }

    fun isHeader(): Boolean {
        return headerFooterType == TYPE_HEADER
    }

    fun isFooter(): Boolean {
        return headerFooterType == TYPE_FOOTER
    }

}